﻿using SelfManagement.Database.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace SelfManagement.Database.POCO
{
    [Table("Article")]
    public class Article : UserBase
    {
        /// <summary>
        /// 文章标题
        /// </summary>
        [Required]
        [StringLength(200)]
        public string Title { get; set; }

        /// <summary>
        /// 文章内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }

        [Required]
        public string Category_Id { get; set; }

        /// <summary>
        /// 文章分类
        /// </summary>
        [ForeignKey("Category_Id")]
        public virtual ArticleCategory Category { get; set; }

        /// <summary>
        /// 浏览访问权限 => 默认所有人可见
        /// </summary>
        public ArticlePermission ViewPermission { get; set; } = ArticlePermission.Public; 

        /// <summary>
        /// 是否置顶
        /// </summary>
        public bool IsTop { get; set; }

        /// <summary>
        /// 访问人数
        /// </summary>
        public int ViewCount { get; set; }
        
    }

    public enum ArticlePermission
    {
        [Description("公开")]
        Public,
        [Description("仅好友可见")]
        Friend,
        [Description("指定用户可见")]
        Somebody,
        [Description("仅自己可见")]
        Self
    }
}
